package com.hospital.workstation.controller;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import com.hospital.workstation.domain.bo.PillEducationBo;
import com.hospital.workstation.domain.vo.PillEducationVo;
import lombok.RequiredArgsConstructor;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;

import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.hospital.common.annotation.RepeatSubmit;
import com.hospital.common.annotation.Log;
import com.hospital.common.core.controller.BaseController;
import com.hospital.common.core.domain.PageQuery;
import com.hospital.common.core.domain.R;
import com.hospital.common.core.validate.AddGroup;
import com.hospital.common.core.validate.EditGroup;
import com.hospital.common.core.validate.QueryGroup;
import com.hospital.common.enums.BusinessType;
import com.hospital.common.utils.poi.ExcelUtil;
import com.hospital.workstation.domain.vo.PillSuggestVo;
import com.hospital.workstation.domain.bo.PillSuggestBo;
import com.hospital.workstation.service.IPillSuggestService;
import com.hospital.common.core.page.TableDataInfo;

/**
 * 用药建议
 *
 * @author whb
 * @date 2023-03-10
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/workstation/pillSuggest")
public class PillSuggestController extends BaseController {

    private final IPillSuggestService iPillSuggestService;

    /**
     * 根据病历号获取用药建议信息
     *
     * @param medicalRecordNo 病历号
     * @return
     */
    @SaCheckPermission("workstation:pillSuggest:query")
    @GetMapping("/{medicalRecordNo}")
    public R<PillSuggestVo> queryPillSuggestInfo(@PathVariable Integer medicalRecordNo) {
        return R.ok(iPillSuggestService.queryByMedicalRecordNo(medicalRecordNo));
    }

    /**
     * 保存
     *
     * @param bo 用药建议业务对象
     * @return
     */
    @SaCheckPermission("workstation:pillSuggest:save")
    @Log(title = "保存用药建议", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> save(@RequestBody PillSuggestBo bo) {
        return toAjax(iPillSuggestService.save(bo));
    }
}
